/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.chenweihuacwh.service.orderManage;

import com.javaeye.chenweihuacwh.dto.orderManage.CustomerOrder;
import com.javaeye.chenweihuacwh.dto.orderManage.Reason;
import com.javaeye.chenweihuacwh.util.DateUtils;

public class OrderBusinessService extends OrderService {
	
	public void saveOrder(CustomerOrder order) {
		double hours = DateUtils.getDateOffsetHour(order.getUpdateDate(), DateUtils.now());
		if (hours > Reason.LATER_HOUR) {
			Reason reason = new Reason(Reason.REASON_CATEGORY_BUSINESS,
					order.getId(),
					"业务确认在计划安排完成" + Reason.LATER_HOUR + "个小时之后");
			getReasonDao().saveReason(reason);
		}
		
		//更新出货单为已经业务确认状态
		order.setStatus(ORDER_STATES_BUSINESS);
		order.setUpdateDate(DateUtils.now());
		getDao().saveOrder(order);
	}

}
